<template>
    <div>
<h1>科室修改</h1>
<a href="/GetKs">去科室显示</a>
<table class="table">
    <tbody>
        <tr>
            <td>科室名称</td>
            <td>
                <input type="text" v-model="data.kName">
            </td>
        </tr>
        <tr>
            <td>科室人数</td>
            <td>
                <input type="text" v-model="data.numRs">
            </td>
        </tr>
        <tr>
            <td>科室描述</td>
            <td>
                <textarea v-model="data.magges"></textarea>
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" value="更新" class="btn btn-success" @click="AddKs">
            </td>
        </tr>
    </tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { useRoute } from 'vue-router';
var route=useRoute();
var router=useRouter();
onMounted(()=>{
GetFt();
})
const data=ref({
      "kid": 0,
  "kName": "",
  "numRs": 0,
  "magges": "",
  "datetimes": "2025-05-19T02:23:06.700Z",
  "isDel": true
})

const  GetFt=()=>{
    var mid=route.query.id;
    axios.get("/api/Ks/GetFt",{params:{id:mid}}).then(res=>{
        data.value=res.data;
    })
}

const AddKs=()=>{
    axios.put("/api/Ks/UpdateKs",data.value).then(res=>{
    if(res.data>0)
    {
        alert("修改成功");
        router.push({path:"/GetKs"})
    }
    else
    {
        alert("修改失败");
    }
    })
}
</script>

<style scoped>

</style>